package ude.univ.esiag.gon.uchiha.operation;

import java.io.Serializable;

import ude.univ.esiag.gon.uchiha.data.DataObject;

public class Operation implements Serializable{
	private static final long serialVersionUID = 1L;
	// type
	public static final int IOR = 0;
	public static final int BOOTSTRAP = 1;
	public static final int CREATE = 2;
	public static final int GETIOR = 3;
	public static final int SETIOR = 4;
	public static final int WRITE = 5;
	public static final int READ = 6;
	public static final int ERROR = 7;
	public static final int CREATES = 8;
	
	// target
	public static final int TOPIC = 0;
	public static final int CACHE = 1;
	
	private int type;
	private int target;
	private boolean toReplicate;
	private DataObject data;
	
	public Operation(String topicName, Object obj) {
		data = new DataObject(obj);
		data.setTopicName(topicName);
	}
	public boolean isToReplicate() {
		return toReplicate;
	}
	public void setToReplicate(boolean toReplicate) {
		this.toReplicate = toReplicate;
	}
	public DataObject getData() {
		return data;
	}
	public void setData(DataObject data) {
		this.data = data;
	}
	public int getType() {
		return type;
	}
	public void setType(int type) {
		this.type = type;
	}
	public void setTarget(int target) {
		this.target = target;
	}
	public int getTarget() {
		return target;
	}
	@Override
	public String toString() {
		return "OPERATION:" + getTarget() + getType() + isToReplicate() + "[" + getData().getTopicName() + "/" + getData().getObj().getClass() + "]";
	}
}
